package com.software.graduationproject.commons.util;

import com.software.graduationproject.commons.enums.ResultCodes;
import com.v2coding.validate.BaseResultCode;

/**
 * 返回结果集
 */
public class Results {
    public Results() {
    }
    public static <T> Result<T> success() {
        return (Result<T>) Result.builder().success(true).code(ResultCodes.SUCCESS.getStatus()).message(ResultCodes.SUCCESS.getMessage()).build();
    }

    public static <T> Result<T> success(T data) {
        return (Result<T>) Result.builder().success(true).code(ResultCodes.SUCCESS.getStatus()).data(data).message(ResultCodes.SUCCESS.getMessage()).build();
    }

    public static <T> Result<T> failure() {
        return (Result<T>) Result.builder().success(false).code(ResultCodes.FAILURE.getStatus()).message(ResultCodes.FAILURE.getMessage()).build();
    }

    public static <T> Result<T> failure(String message) {
        return (Result<T>) Result.builder().success(false).code(ResultCodes.FAILURE.getStatus()).message(message).build();
    }

    public static <T> Result<T> failure(Integer code, String message) {
        return (Result<T>) Result.builder().success(false).code(code).message(message).build();
    }
}
